package longcaisuyun.longcai.com.net;

import android.util.Log;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

import longcaisuyun.longcai.com.suyunbean.ShopBean;

/**
 * Created by Administrator on 2016/4/26.
 */
@HttpInlet(Net.SHOP)
public class PostShop extends WHAsyPost<PostShop.Info> {
    public String typeid;

    public PostShop(String typeid, AsyCallBack asyCallBack) {
        super(asyCallBack);
        this.typeid = typeid;
    }

    @Override
    protected Info parser(JSONObject object) {
        Info info = new Info();
        try {
            info.message = object.getString("message");
            if (info.message.equals("1")) {
                Log.e("我的size",object.getJSONArray("list").length()+"");
                for (int j = 0; j < object.getJSONArray("list").length(); j++) {
                    ShopBean shopBean = new ShopBean();
                    shopBean.setTitle(object.getJSONArray("list").getJSONObject(j).getString("title"));
                    shopBean.setTypeid(object.getJSONArray("list").getJSONObject(j).getString("typeid"));
                    shopBean.setPicurl(object.getJSONArray("list").getJSONObject(j).getString("picurl"));
                    info.list.add(shopBean);

                }
            }
            return info;
        } catch (JSONException e) {
            e.printStackTrace();
            Log.e("失败啦","");
        }
        return null;
    }

    public static class Info {
        public String message;
        public List<ShopBean> list = new ArrayList<>();
    }
}
